<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns="http://www.springframework.org/schema/beans"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
                           http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/context 
                           http://www.springframework.org/schema/context/spring-context.xsd" >

    <!-- Define the controllers using annotations -->

    <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />

    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />

    <context:component-scan base-package="ctrl" />

    <!-- Die folgenden beiden Teile wurden ausgelagert, damit der data-access-context für Unit-Tests wiederverwendet werden kann. -->


    <!-- ******************* -->
    <!-- Database (MySQL-DB laueft extern) -->
    <!-- ******************* -->

    <bean
        id="init"
        class="cs.Startup"
        init-method="initDB" >

        <property
            name="driverClass"
            value="com.mysql.jdbc.Driver" />

        <property
            name="user"
            value="schneeberger" />

        <property
            name="password"
            value="SuZHdhcEhUMeNLB8" />

        <property
            name="defaultDBurl"
            value="jdbc:mysql://www.coreser.com:3306/schneeberger" />

        <property
            name="newDB"
            value="cs" />
    </bean>

    <bean
        id="dataSource"
        class="com.mchange.v2.c3p0.ComboPooledDataSource"
        depends-on="init"
        destroy-method="close" >

        <property
            name="driverClass"
            value="com.mysql.jdbc.Driver" />

        <property
            name="jdbcUrl"
            value="jdbc:mysql://www.coreser.com:3306/schneeberger" />

        <property
            name="user"
            value="schneeberger" />

        <property
            name="password"
            value="SuZHdhcEhUMeNLB8" />

        <property
            name="minPoolSize"
            value="2" />

        <property
            name="maxPoolSize"
            value="4" />
    </bean>

    <!-- ******************* -->
    <!-- Data Access -->
    <!-- ******************* -->

    <import resource="data-access-context.xml" />

    <!-- ******************* -->
    <!-- Controllers -->
    <!-- ******************* -->

    <bean
        id="personController"
        class="ctrl.PersonController" >

        <property
            name="personDao"
            ref="personDao" />

        <property
            name="loginCredentials"
            ref="loginCredentials" />

        <property
            name="typStatusDao"
            ref="typStatusDao" />
    </bean>

    <bean
        id="angebotController"
        class="ctrl.AngebotController" >

        <property
            name="angebotstypDao"
            ref="angebotstypDao" />

        <property
            name="personDao"
            ref="personDao" />

        <property
            name="loginCredentials"
            ref="loginCredentials" />
    </bean>

    <bean
        id="anfrageController"
        class="ctrl.AnfrageController" >

        <property
            name="anfrageDao"
            ref="anfrageDao" />

        <property
            name="personDao"
            ref="personDao" />

        <property
            name="loginCredentials"
            ref="loginCredentials" />
    </bean>

    <!-- ******************* -->
    <!-- Views -->
    <!-- ******************* -->


    <!-- Als Präfix den Name z.B. home von der Controller Datei -->

    <bean
        id="viewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver" >

        <property
            name="prefix"
            value="/view/" />

        <property
            name="suffix"
            value=".jsp" />
    </bean>

</beans>